package com.ss.android.pay;

import java.util.ArrayList;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
import org.json.JSONObject;

public final class h {
    public String a;
    public String b;
    public String c;
    public String d;
    public String e;
    public String f;
    public String g;
    public String h;
    public String i;
    public int j;
    public String k;

    public h() {

    }

    public static h a(String arg9) {
        Object v0_2;
        int v1 = 1;
        h v2 = new h();
        try {
            JSONObject v0_1 = new JSONObject(arg9).optJSONObject("data");
            if(v0_1 == null) {
                return v2;
            }

            JSONObject v3 = v0_1.optJSONObject("sdk_info");
            v0_1 = v0_1.optJSONObject("trade_info");
            if(v3 != null) {
                v2.a = v3.optString("sign");
                v3.optString("package");
                v2.b = v3.optString("timestamp");
                v2.c = v3.optString("partnerid");
                v2.d = v3.optString("appid");
                v2.e = v3.optString("prepayid");
                v2.f = v3.optString("noncestr");
                v2.h = v3.optString("sign_type");
                v2.g = v3.optString("order_info");
            }

            if(v0_1 != null) {
                v2.i = v0_1.optString("tt_sign");
                v0_1.optString("call_back_url");
                v2.j = v0_1.optInt("way", 1);
                v0_1.optString("tt_sign_type");
            }

            if(v3 == null) {
                return v2;
            }

            if(v0_1 == null) {
                return v2;
            }

            ArrayList v3_1 = new ArrayList();
            JSONObject v4 = new JSONObject(v0_1.toString());
            ((List)v3_1).add(new g("sign", v2.a));
            v4.remove("tt_sign");
            v4.remove("tt_sign_type");
            Iterator v5 = v4.keys();
            while(v5.hasNext()) {
                v0_2 = v5.next();
                ((List)v3_1).add(new g(((String)v0_2).toLowerCase(), v4.optString(((String)v0_2), "")));
            }

            Collections.sort(((List)v3_1), new i());
            StringBuilder v4_1 = new StringBuilder();
            Iterator v3_2 = ((List)v3_1).iterator();
            while(v3_2.hasNext()) {
                v0_2 = v3_2.next();
                if(v1 == 0) {
                    v4_1.append("&");
                }

                v1 = 0;
                v4_1.append(((g)v0_2).a).append("=").append(((g)v0_2).b);
            }

            v2.k = v4_1.toString();
        }
        catch(Throwable v0) {
            v0.printStackTrace();
        }

        return v2;
    }
}

